Skip to content

nixos/mailman: postorius & hyperkitty support#67951

Merged
peti merged 6 commits intoNixOS:masterfrom
peti:t/mailman
Sep 11, 2019
Merged

nixos/mailman: postorius & hyperkitty support#67951
peti merged 6 commits intoNixOS:masterfrom
peti:t/mailman

Conversation

@peti
Copy link
Member

@peti peti commented Sep 2, 2019

A simple Apache configuration for running Postorious and Hyperkitty looks as follows:

httpd = let webRoot = config.services.mailman.webRoot; in {
  enable = true;
  adminAddr = "postmaster@example.org";
  hostName = "lists.example.org";
  logPerVirtualHost = true;
  extraModules = [ { name = "wsgi"; path = "${pkgs.apacheHttpdPackages.mod_wsgi3}/modules/mod_wsgi.so"; } ];
  extraConfig = ''                                                                                                                                                                                                  
    WSGISocketPrefix /run/httpd/wsgi                                                                                                                                                                                
    WSGIDaemonProcess mailman threads=25 home=/var/lib/mailman-web python-path=${webRoot}:${
      lib.makeSearchPath pkgs.python3.sitePackages
        pkgs.python3Packages.mailman-web.requiredPythonModules
    }                                                                       
  '';
  virtualHosts = [
    { hostName = "lists.example.org";
      documentRoot = config.security.acme.certs."lists.example.org".webroot;
      extraConfig = ''                                                                                                                                                                                              
        <Directory "${config.security.acme.certs."lists.example.org".webroot}">                                                                                                                                     
          Options -Indexes                                                                                                                                                                                          
        </Directory>                                                                                                                                                                                                
        RedirectMatch permanent ^(?!/\.well-known/acme-challenge/).* https://lists.example.org$0                                                                                                                    
                                                                                                                                                                                                                    
      '';
    }
    { hostName = "lists.example.org";
      enableSSL = true;
      sslServerCert = "/var/lib/acme/lists.example.org/fullchain.pem";
      sslServerKey = "/var/lib/acme/lists.example.org/key.pem";
      servedDirs = [ { dir = "/var/lib/mailman-web/static"; urlPath = "/static"; } ];
      extraConfig = ''                                                                                                                                                                                              
        <Directory "${webRoot}">                                                                                                                                                                                    
          <Files wsgi.py>                                                                                                                                                                                           
            Require all granted                                                                                                                                                                                     
          </Files>                                                                                                                                                                                                  
          WSGIProcessGroup mailman                                                                                                                                                                                  
        </Directory>                                                                                                                                                                                                
        WSGIScriptAlias / ${webRoot}/wsgi.py                                                                                                                                                                        
      '';
    }
    { hostName = "localhost";
      servedDirs = [ { dir = "/var/lib/postorius/static"; urlPath = "/static"; } ];
      extraConfig = ''                                                                                                                                                                                              
        <Directory "${webRoot}">                                                                                                                                                                                    
          <Files wsgi.py>                                                                                                                                                                                           
            Require ip 127.0.0.1                                                                                                                                                                                    
            Require all granted                                                                                                                                                                                     
          </Files>                                                                                                                                                                                                  
          WSGIProcessGroup mailman                                                                                                                                                                                  
        </Directory>                                                                                                                                                                                                
        WSGIScriptAlias / ${webRoot}/wsgi.py                                                                                                                                                                        
      '';
    }
  ];
};

[1] https://gitlab.com/mailman/hyperkitty/tree/master/example_project

@peti peti added 0.kind: enhancement Add something new or improve an existing system. 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 2.status: work-in-progress 8.has: module (update) This PR changes an existing module in `nixos/` labels Sep 2, 2019
@peti peti added this to the 19.09 milestone Sep 2, 2019
@peti peti requested a review from globin September 2, 2019 14:28
@peti peti self-assigned this Sep 2, 2019
@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux. labels Sep 2, 2019
@peti peti requested a review from FRidh as a code owner September 10, 2019 15:16
@peti peti changed the title [WIP] nixos/mailman: hyperkitty support nixos/mailman: hyperkitty support Sep 10, 2019
@peti peti changed the title nixos/mailman: hyperkitty support nixos/mailman: postorius & hyperkitty support Sep 10, 2019
@ofborg ofborg bot added the 6.topic: python Python is a high-level, general-purpose programming language. label Sep 10, 2019
@peti
Copy link
Member Author

peti commented Sep 10, 2019

I've been running this code on my server for a while now and consider it good enough(tm) to be useful to others.

@ofborg ofborg bot added 8.has: package (new) This PR adds a new package 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. and removed 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux. labels Sep 10, 2019
@ofborg ofborg bot added the 2.status: merge conflict This PR has merge conflicts with the target branch label Sep 10, 2019
@peti peti force-pushed the t/mailman branch 2 times, most recently from 953a418 to b129dc1 Compare September 10, 2019 17:49
@ofborg ofborg bot removed the 2.status: merge conflict This PR has merge conflicts with the target branch label Sep 10, 2019
@ofborg ofborg bot added the 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. label Sep 10, 2019
@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. and removed 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. labels Sep 10, 2019
@FRidh
Copy link
Member

FRidh commented Sep 11, 2019 via email

@peti
Copy link
Member Author

peti commented Sep 11, 2019

It is not a Python module that is usable otherwise.

Users of Nixpkgs can use that module to set up the Mailman Web UI outside of NixOS.

@FRidh
Copy link
Member

FRidh commented Sep 11, 2019 via email

@peti
Copy link
Member Author

peti commented Sep 11, 2019

Great, then it needs to become a proper package.

I am sorry, @FRidh. I am aware of the fact that you dedicate a lot of time and effort into maintaining the Python infrastructure. I also realize that you perform a lot of updates, make sure everything works, and are actively maintaining that part of Nixpkgs here on Github. I totally respect that and I'd like to use the occasion to say thank you for all those efforts for all those years, which have benefited me greatly.

Having said that, the issue we are discussing here is a trivial minutiae that seems totally inconsequential. I don't understand where do you want to go with this. You seem to be pulling all kinds of rules and conventions out of thin air just for the sake of having something to criticize.

@FRidh
Copy link
Member

FRidh commented Sep 11, 2019

@peti initially it did not make sense to me to have mailman-web in there because it appeared to be configuration only for a module. You then made the point that it actually can be reusable, and I agree now with that. We actually do this in other places as well (I recall jupyter notebook or lab), where the logic is not included in the module so it can be used elsewhere.

Right now, the issue is that the modules are not in a site-package folder. That means that, by default, they are not importable. To make them importable they should be in a site-packages folder, or an environment variable like PYTHONPATH needs to be used to make them importable. In the module, you made it work because PYTHONPATH is set using the --pythonpath attribute.

The Python packages is meant only for packages that provide importable packages and modules. That means the modules need to be in a site-packages folder and the derivation marked in a certain way, using toPyhonModule (which buildPythonPackage) already does. Functions like python.buildEnv and python.withPackages rely on this. This is the part that matters to me and why I have this discussion.

Now, Django configuration is typically not put in a default site-packages folder because on systems the dependencies are often put separate from the web application configuration, however, there is no harm in doing so.

@peti
Copy link
Member Author

peti commented Sep 11, 2019

OK. That makes sense. I'll make the necessary changes to mailman-web.

When mailman-web restarts, it removes the generated "static" directory. This
breaks a currently running httpd process, which needs a re-start, too, to
obtain a new handle for the newly generated path.
@peti peti merged commit 5ba6173 into NixOS:master Sep 11, 2019
@ofborg ofborg bot added 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. and removed 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. labels Sep 11, 2019
peti added a commit to peti/nixpkgs that referenced this pull request Sep 11, 2019
…-shift Python library

Suggested in NixOS#67951 (comment).

(cherry picked from commit 86f8895)
matthuszagh pushed a commit to matthuszagh/nixpkgs that referenced this pull request Sep 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

0.kind: enhancement Add something new or improve an existing system. 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 6.topic: python Python is a high-level, general-purpose programming language. 8.has: module (update) This PR changes an existing module in `nixos/` 8.has: package (new) This PR adds a new package 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants